#include <bits/stdc++.h>
using namespace std;

int deg[26], fa[26], cc;
bool hav[26];

int findset(int x){
    return fa[x]==x? x:fa[x] = findset(fa[x]);
}

bool con(){
    for (bool i : hav) {
        if(!i) --cc;
    }
    return cc==1;
}

bool euler(){
   vector<int> d;
    for (int i = 0; i < 26; ++i) {
        if(deg[i]) d.push_back(deg[i]);
    }
    return d.empty() || (d.size()==2 && (d[0]==1 || d[0]==-1));
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int T; cin >> T;
    while(T--){
        memset(deg, 0, sizeof(deg));
        memset(hav, false, sizeof(hav));
        cc = 26;
        for (int i = 0; i < 26; ++i) fa[i] = i;

        int N; cin >> N;
        string s;
        for (int i = 0; i < N; ++i) {
            cin >> s;
            int i1 = s.front()-'a';
            int i2 = s.back()-'a';
            ++deg[i1]; --deg[i2];
            hav[i1] = hav[i2] = true;
            int fa1 = findset(i1), fa2 = findset(i2);
            if(fa1 != fa2) {fa[fa1] = fa2; --cc;}
        }
        if(con() && euler()) cout << "Ordering is possible.\n";
        else cout << "The door cannot be opened.\n";
    }
    return 0;
}